﻿using System;
using System.Data.SqlServerCe;
using SerbinAV.MobileSales.Sales.Entities;

namespace SerbinAV.MobileSales.Sales.DAL
{
    public class DataManager:IDataManager
    {

        private string _connectionString;

        public DataManager(string connectionString)
        {
            _connectionString = connectionString;
        }

        public string ConnectionString
        {
            get { return _connectionString; }
            set { _connectionString = value; }
        }

        public void VerifyConnection ()
        {
            using (SqlCeConnection con = new SqlCeConnection(_connectionString))
            {
                con.Open();
            }

        }

        private IVisitRepository _visits;

        public IVisitRepository Visits
        {
            get
            {
                return _visits ?? (_visits = new VisitRepository(_connectionString));
            }
        }

        //    private OrderRepository _orders;
        //    public OrderRepository Orders
        //    {
        //        get { return _orders ?? (_orders = new OrderRepository()); }
        //    }

        //    private OrderRecordRepository _orderRecords;
        //    public OrderRecordRepository OrderRecords
        //    {
        //        get
        //        {
        //            return _orderRecords ?? (_orderRecords = new OrderRecordRepository());
        //        }
        //    }

        //    private BuyPointRepository _buyPoints;
        //    public  BuyPointRepository BuyPoints
        //    {
        //        get
        //        {
        //            return _buyPoints ?? (_buyPoints = new BuyPointRepository());
        //            }
        //    }

        //    private SheduleVisitsRepository _sheduleVisits;
        //    public SheduleVisitsRepository SheduleVisits
        //    {
        //        get
        //        {
        //            return _sheduleVisits ?? (_sheduleVisits = new SheduleVisitsRepository());
        //        }
        //    }

        //    private BuyerRepository _buyers;
        //    public BuyerRepository Buyers
        //    {
        //        get
        //        {
        //            return _buyers ?? (_buyers = new BuyerRepository());
        //        }
        //    }

        //    private GoodRepository _goods;
        //    public GoodRepository Goods
        //    {
        //        get
        //        {
        //            return _goods ?? (_goods = new GoodRepository());
        //        }
        //    }

        //    private GroupRepository _groups;
        //    public GroupRepository Groups
        //    {
        //        get
        //        {
        //            return _groups ?? (_groups = new GroupRepository());
        //        }
        //    }

        //    private TradeMarkRepository _tradeMarks;
        //    public TradeMarkRepository TradeMarks
        //    {
        //        get
        //        {
        //            return _tradeMarks ?? (_tradeMarks = new TradeMarkRepository());
        //        }
        //    }

        private ISkladRepository _sklads;
        public ISkladRepository Sklads
        {
            get
            {
                return _sklads ?? (_sklads = new SkladRepository(_connectionString));
            }

        }

        //    private RemainingRepository _remainingRepository;
        //    public RemainingRepository Remainings
        //    {
        //        get
        //        {
        //            return _remainingRepository ?? (_remainingRepository = new RemainingRepository());
        //        }
        //    }
        //}

    }
}
